'use strict'

process.chdir(__dirname)

const parseArgv = require('../index')

let ret = parseArgv({
  '@autoDefault': true,

  '@command': [
    'create', 'delete', 'update', 'show'
  ],

  '@defaultCommand': 'show',

  '$1': {
    callback: (v) => {
      return ['oo', 'ii', 'cc'].indexOf(v) >= 0 ? v : 'oo'
    }
  },

  '$2': {
    type: 'string',
    callback: (v) => {
      return !!parseInt(v)
    }
  },

  '--port=' : {
    name: 'port',
    alias: '-p',
    type: 'int',
    min: 2000,
    max: 2100
  },

  '--host=' : {
    name: 'host',
    match: /^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/i
  },

  '-w' : {
    name: 'worker',
    //type: 'int',
    min: 1,
    max: 4,
    default: 2
  },

  '--https': {
    name: 'https'
  },

  '--http2': {
    name: 'http2'
  },

  '--test': {
    name: 'test'
  },

  '--id' : {
    name : 'id',
    callback: (str) => {
      return str.split(',').filter(p => p.length > 0)
    }
  },

  '--limit' : 'limit'

})

console.log(ret)
